import 'package:flutter/material.dart';
import 'package:mall/core/models/product_detail.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 商品价格
class ProductPrice extends StatelessWidget {
  final List<Price> list;
  final Color color;
  final double fontSize;

  const ProductPrice({
    Key key,
    @required this.list,
    this.color,
    this.fontSize,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Text.rich(
      TextSpan(
        style: TextStyle(
          color: color ?? Theme.of(context).primaryColor,
          fontSize: fontSize ?? 12.sp,
        ),
        children: list.map((e) => TextSpan(text: '${e.flag}${e.pointCoinString} ')).toList(),
      ),
    );
  }
}
